package com.amumu.drama.common.constant;

import com.google.common.collect.Maps;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;

/**
 * @author sunzhuang
 * @date 2024/5/30 17:43
 * @slogan 天下风云出我辈, 一入代码岁月催
 * @desc 充值状态(untreated : 未处理, processing : 处理中, success : 成功, failed : 失败
 */
@Getter
public enum FuluOrderStatusEnum {
    /** 福禄充值状态 */
    UNTREATED("untreated", "未处理"),
    PROCESSING("processing", "处理中"),
    SUCCESS("success", "成功"),
    FAILED("failed", "失败");

    FuluOrderStatusEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    private String code;

    private String desc;

    private static Map<String, FuluOrderStatusEnum> UNINDEX = Maps.uniqueIndex(Arrays.asList(values()), FuluOrderStatusEnum::getCode);

    public FuluOrderStatusEnum getByCode(String code) {
        if (code == null) {
            return null;
        }
        return UNINDEX.getOrDefault(code, null);
    }
}
